package com.wlcorp.forcazamis.sys.util;

import org.springframework.web.context.WebApplicationContext;

import com.wlcorp.forcazamis.business.baseinfo.ICustomerService;
import com.wlcorp.forcazamis.business.baseinfo.IDepotService;
import com.wlcorp.forcazamis.business.baseinfo.IFactoryService;
import com.wlcorp.forcazamis.business.baseinfo.IFeatureService;
import com.wlcorp.forcazamis.business.baseinfo.ISampleSourceService;
import com.wlcorp.forcazamis.business.baseinfo.ISampleTypeService;
import com.wlcorp.forcazamis.business.confirm.IConfirmService;
import com.wlcorp.forcazamis.business.message.IMessageService;
import com.wlcorp.forcazamis.business.pi.IPidetailService;
import com.wlcorp.forcazamis.business.sample.ISampleService;
import com.wlcorp.forcazamis.business.stock.IStockService;
import com.wlcorp.forcazamis.business.storageassign.IStorageAssignService;
import com.wlcorp.forcazamis.business.storagein.IStorageInService;
import com.wlcorp.forcazamis.business.storageout.IStorageOutService;
import com.wlcorp.forcazamis.business.system.ICompanyService;
import com.wlcorp.forcazamis.business.system.IDepartmentService;
import com.wlcorp.forcazamis.business.system.IRoleService;
import com.wlcorp.forcazamis.business.system.IStaffService;


public class ContextUtil {

	private static ContextUtil contextUtil = null;

	private ContextUtil() {
	}

	public static ContextUtil getInstance() {
		if (contextUtil == null) {
			contextUtil = new ContextUtil();
		}
		return contextUtil;
	}

	private static WebApplicationContext context;

	public void setContext(WebApplicationContext event) {
		context = event;
	}

	public static WebApplicationContext getContext() {
		return context;
	}

	public Object getBean(String service) {
		return context.getBean(service);
	}
	
	public ICompanyService getCompanyService(){
		return (ICompanyService)context.getBean("companyService");
	}
	
	public IRoleService getRoleService(){
		return (IRoleService)context.getBean("roleService");
	}
	
	public IDepartmentService getDepartmentService(){
		return (IDepartmentService)context.getBean("departmentService");
	}
	
	public IStaffService getStaffService(){
		return (IStaffService)context.getBean("staffService");
	}
	
	public ISampleSourceService getSampleSourceService(){
		return (ISampleSourceService)context.getBean("sampleSourceService");
	}
	public ICustomerService getCustomerService(){
		return (ICustomerService)context.getBean("customerService");
	}
	
	public ISampleTypeService getSampleTypeService(){
		return (ISampleTypeService)context.getBean("sampleTypeService");
	}
	
	public IFeatureService getFeatureService(){
		return (IFeatureService)context.getBean("featureService");
	}
	public IFactoryService getFactoryService(){
		return (IFactoryService)context.getBean("factoryService");
	}
	
	public ISampleService getSampleService(){
		return (ISampleService)context.getBean("sampleService");
	}
	
	public IDepotService getDepotService(){
		return (IDepotService)context.getBean("depotService");
	}
	
	public IStorageInService getStorageInService(){
		return (IStorageInService)context.getBean("storageInService");
	}
	
	public IStorageOutService getStorageOutService(){
		return (IStorageOutService)context.getBean("storageOutService");
	}
	
	public IStorageAssignService getStorageAssignService(){
		return (IStorageAssignService)context.getBean("storageAssignService");
	}
	
	public IConfirmService getConfirmService(){
		return (IConfirmService)context.getBean("confirmService");
	}
	
	public IPidetailService getPidetailService(){
		return (IPidetailService)context.getBean("pidetailService");
	}
	
	public IStockService getStockService(){
		return (IStockService)context.getBean("stockService");
	}
	
	public IMessageService getMessageService(){
		return (IMessageService)context.getBean("messageService");
	}
}